# 导入 requests 包
import requests

res = requests.post(
    "http://127.0.0.1:8000/test1", data={"select": "id,name,age", "where": "id > 3"}
)
print(res.text)
""" 
form: {'select': ['id,name,age'], 'where': ['id > 3']} 
select: 'id,name,age', where: 'id > 3'
"""
print("\n")

res = requests.post("http://127.0.0.1:8000/test2", data="xxx")
print(res.text) # xxx
print("\n")

res = requests.post("http://127.0.0.1:8000/test2", data={"a": 1, "b": 2})
print(res.content) # b'a=1&b=2'
print("\n")

res = requests.post(
    "http://127.0.0.1:8000/test3", json={"name": "Hanko", "where": "BJ"}
)
print(res.text)
print("\n")

res = requests.post(
    "http://127.0.0.1:8000/test4",
    files={
        "樱花庄": open(
            r"C:\cygwin64\home\admin\python\sanic_hello\04-response\1.txt", "rb"
        )
    },
)
# 上传的文件名: 1.txt, 文件内容: It's 1.txt, 文件类型: text/plain
print(res.text) 
print("\n")
